package com.wngbms.redisson;

import com.wngbms.redisson.bean.DemoBean;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RBucket;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class BaseOps {

//    @Autowired
//    RedissonClient redissonClient;

    @Bean
    public ApplicationRunner r1(RedissonClient redissonClient) {
        return args -> {

            RBucket<DemoBean> buck = redissonClient.getBucket("buck");

            DemoBean build = DemoBean.build();
            buck.set(build);

            DemoBean demoBean = buck.get();

            log.info("demoBean:{}", demoBean);
        };
    }


}
